Skip to content

fix(payment): stop truncating revert reasons and persist payment errors to a log file - #205

Merged
Nic-dorman merged 1 commit into
mainfrom
fix/payment-error-visibility
Aug 7, 2026
Merged

fix(payment): stop truncating revert reasons and persist payment errors to a log file#205
Nic-dorman merged 1 commit into
mainfrom
fix/payment-error-visibility

Conversation

@Nic-dorman

Copy link
Copy Markdown
Member

Problem

A tester's payment failure on v0.9.6-rc.2 arrived as a screenshot ending mid-sentence:

Failed: Payment failed: Payment would fail on-chain: The contract function "payForMerkleTree" reverted with the following signature:

Two independent gaps made that report undiagnosable:

  1. The revert payload was truncated by our own code. viem formats reverts as …the following signature:\n0x<selector> — the selector sits on a second line of shortMessage, and both shortReason() (utils/payment.ts) and paymentErrorSummary() (stores/files.ts) cut at the first newline. The one string identifying why the contract reverts never reached the UI.
  2. Nothing was persisted. The frontend's console.error dies in the webview (production ships without devtools), Rust tracing wrote to stderr only (discarded for a windowed app), and upload_history.json persists completed uploads only. The screenshot was literally the only artifact.

Fix

  • Flatten newlines in shortReason() / paymentErrorSummary() so the selector or reason string survives into the status label and toast. Size impact on the UI: a selector is 10 chars (0x + 8 hex); a decoded reason is a short sentence — no risk of the old full-dump overflow, which came from viem's multi-line .message and stays out of the UI.
  • New log_frontend_error commandpaymentErrorSummary now mirrors the full dump (message + stack for the whole cause chain, so the wrapped viem diagnostics survive the preflight's plain-Error wrapper) into Rust tracing under target ant_gui::frontend, fire-and-forget.
  • Rolling log file — the tracing subscriber gains a file layer: ~/.config/autonomi/ant-gui/logs/ant-gui.<date>.log (platform config-dir equivalent), daily rotation, 7 files kept, ANSI off. The stderr layer is unchanged for dev; if the log dir is unwritable the app falls back to stderr-only.

Testing

  • Vitest 67/67, including a new regression test asserting the selector survives on one line.
  • nuxi typecheck, cargo check, clippy -D warnings, fmt --check all clean.

🤖 Generated with Claude Code

…rs to a log file

A tester's rc.2 failure arrived as a screenshot ending at "reverted with
the following signature:" - viem puts the revert selector/reason on a
second line of shortMessage, and both shortReason() and
paymentErrorSummary() truncated at the first newline. The selector is
the only clue to WHY a payment reverts, and it was also captured
nowhere: the webview console.error is unreachable in production (no
devtools) and Rust tracing wrote to stderr only (discarded for a
windowed app).

- Flatten newlines in shortReason()/paymentErrorSummary() so the
  selector (10 chars, e.g. 0x1fb3b5a2) or reason string survives into
  the status label and toast.
- Mirror the full payment error dump (message + stack of the whole
  cause chain, so the wrapped viem diagnostics survive) into Rust
  tracing via a new log_frontend_error command.
- Give the tracing subscriber a rolling file layer:
  ~/.config/autonomi/ant-gui/logs/ant-gui.<date>.log, daily rotation,
  7 files kept, stderr layer unchanged. Falls back to stderr-only if
  the log dir is unwritable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nic-dorman
Nic-dorman merged commit 261d867 into main Aug 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant